<template><div><h2 id="表单初始化" tabindex="-1"><a class="header-anchor" href="#表单初始化"><span>表单初始化</span></a></h2>
<p>通过<code v-pre>Form::resolving</code>方法设置的回调函数会在<code v-pre>Dcat\Admin\Form</code>类被实例化时触发；</p>
<p>通过<code v-pre>Form::composing</code>方法设置的回调函数会在<code v-pre>render()</code>方法被调用时（渲染页面时）触发；</p>
<p>开发者可以在这两个事件中改变<code v-pre>Form</code>的一些设置或行为，比如需要禁用掉某些操作，可以在<code v-pre>app/Admin/bootstrap.php</code>加入下面的代码：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Form</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token class-name static-context">Form</span><span class="token operator">::</span><span class="token function">resolving</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">     <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">disableEditingCheck</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">     <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">disableCreatingCheck</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">     <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">disableViewCheck</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">     <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tools</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name class-name-fully-qualified type-declaration">Form<span class="token punctuation">\</span>Tools</span> <span class="token variable">$tools</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">          <span class="token variable">$tools</span><span class="token operator">-></span><span class="token function">disableDelete</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">          <span class="token variable">$tools</span><span class="token operator">-></span><span class="token function">disableView</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">          <span class="token variable">$tools</span><span class="token operator">-></span><span class="token function">disableList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">     <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这样就不用在每一个控制器的代码中来设置了。</p>
<p>如果全局设置后，要在其中某一个表单中开启设置，比如开启显示<code v-pre>继续编辑</code>的checkbox，在对应的实例上调用<code v-pre>$form-&gt;disableEditingCheck(false);</code>就可以了</p>
</div></template>


